//
//  NSScrollView+AnimatedScroll.m
//  WeatherApp
//
//  Created by Yuliya Grasevych on 04.09.14.
//  Copyright (c) 2014 Yuliya Grasevych. All rights reserved.
//

#import "NSScrollView+AnimatedScroll.h"

@implementation NSScrollView (AnimatedScroll)

- (void)scrollToXPosition:(float)xPosition {
    [NSAnimationContext beginGrouping];
    [[NSAnimationContext currentContext] setDuration:1.5];
    NSClipView* clipView = [self contentView];
    NSPoint newOrigin = [clipView bounds].origin;
    newOrigin.x = xPosition;
    [[clipView animator] setBoundsOrigin:newOrigin];
//    [self reflectScrolledClipView: [self contentView]]; // may not bee necessary
    [NSAnimationContext endGrouping];
}

@end
